﻿using Sustainalytics.SharedEntities.EsgResearch;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.CompanyWeightsLogic
{
    public class CompanyWeightsMapper
    {
        public CompanyWeights Map(EsgResearchProfile entity)
        {
            return new CompanyWeights
            {
                Id = Guid.NewGuid(),
                CompanyId = entity.Id,
                Indent = entity.ComputationResult.Indent,
                Weights = entity.ComputationResult.Indicators.ToDictionary(i => i.Code, i => i.Weight.Value)
            };
        }

        public IList<CompanyWeights> MapManyToMany(IList<EsgResearchProfile> entities)
        {
            return entities.Select(Map).ToList();
        }
    }
}
